package com.ly.erms.modular.baseconfig.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.ly.erms.common.persistence.dao.BaseconfigClassificationMapper;
import com.ly.erms.common.persistence.model.BaseconfigClassification;
import com.ly.erms.modular.baseconfig.service.IBaseconfigClassificationService;

/**
 * <p>
 * 分类方案 服务实现类
 * </p>
 *
 * @author liuyang
 * @since 2018-01-16
 */
@Service
public class BaseconfigClassificationServiceImpl
		extends ServiceImpl<BaseconfigClassificationMapper, BaseconfigClassification>
		implements IBaseconfigClassificationService {

	@Resource
	BaseconfigClassificationMapper classificationMapper;

	@Override
	public void deleteClassification(Integer id) {
		BaseconfigClassification classification = classificationMapper.selectById(id);
		Wrapper<BaseconfigClassification> wrapper = new EntityWrapper<>();
		wrapper = wrapper.like("pid", classification.getId().toString());
		List<BaseconfigClassification> subClasses = classificationMapper.selectList(wrapper);
		for (BaseconfigClassification temp : subClasses) {
			temp.deleteById();
		}
		classification.deleteById();
	}

}
